字符串输入

    using namespace std;
    const int ArSize = 20;
    char name[ArSize];
    char dessert[ArSize];

    // cin 使用空白(空格、制表符和换行符)来确定字符串的结束位置。
    // 不能防止输入的内容长度大于数组的长度
    cout << "Enter your name:\n";
    cin >> name;
    cout << "Enter your favorite dessert:\n";
    cin >> dessert;
    cout << "I have some delicious " << dessert;
    cout << " for your, " << name << ".\n";

🔚